import React, { useState } from 'react';

const Case1: React.FC = () => {
  const [num, setNum] = useState(0);

  const handle = () => {
    // setNum(num + 1);
    setNum((num) => num + 1);
    console.log('点击事件里面的num', num); //每一次拿的都是上一次创建的函数作用域里面num的值
  };
  console.log('num', num);
  /*
   */

  return (
    <>
      <div>num:{num}</div>
      <button onClick={handle}>点击+1</button>
    </>
  );
};
export default Case1;
